//
//  YTFlightViewController.m
//  YUNT
//
//  Created by 小萌 on 2017/11/14.
//  Copyright © 2017年 梁炜东. All rights reserved.
//

#import "YTFlightViewController.h"

@interface YTFlightViewController ()

@end

@implementation YTFlightViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"闪关灯";
    // Do any additional setup after loading the view.
    [self loadData];
}
- (void)loadData
{
    YTSetModel *model1 = [[YTSetModel alloc] init];
    model1.name = @"关闭";
    model1.logo = @"34";
    
    YTSetModel *model2 = [[YTSetModel alloc] init];
    model2.name = @"打开";
    model2.logo = @"43";
    
    YTSetModel *model3 = [[YTSetModel alloc] init];
    model3.name = @"自动";
    model3.logo = @"44";

    YTSetModel *model4 = [[YTSetModel alloc] init];
    model4.name = @"常亮";
    model4.logo = @"45";

    if ([YTCameraManager shareModel].captureTorchMode == AVCaptureTorchModeOn) {
        model4.isSelected = YES;
    }else if ([YTCameraManager shareModel].captureFlashMode  == AVCaptureFlashModeOff) {
        model1.isSelected = YES;
    }else if ([YTCameraManager shareModel].captureFlashMode  == AVCaptureFlashModeOn) {
        model2.isSelected = YES;
    }else if ([YTCameraManager shareModel].captureFlashMode  == AVCaptureFlashModeAuto) {
        model3.isSelected = YES;
    }

    self.dataArr = @[model1,model2,model3,model4];
    [self.tableView reloadData];
}
- (void)tableView:(UITableView *)tableView atIndexPath:(NSIndexPath *)indexPath
{
    [super tableView:tableView atIndexPath:indexPath];
    if(indexPath.row == 3){
        [[YTCameraManager shareModel] torchLight:AVCaptureTorchModeOn];
        [[YTCameraManager shareModel] flashLight:AVCaptureFlashModeOff];
    }else{
        [[YTCameraManager shareModel] torchLight:AVCaptureTorchModeOff];
        [[YTCameraManager shareModel] flashLight:indexPath.row];
    }
    BlockCallWithOneArg(self.handler, nil);
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
